package com.skyz.wrap.utils;

import android.os.CountDownTimer;
import android.widget.TextView;

public class CountDownTimerUtils extends CountDownTimer {
    private final static long millisInFuture = 3*60*1000;
    private final static long countDownInterval = 1000;
    TextView tv;

    public CountDownTimerUtils(TextView tv) {
        this(tv,millisInFuture, countDownInterval);// 参数依次为总时长,和计时的时间间隔

    }
    public CountDownTimerUtils(TextView tv,long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);// 参数依次为总时长,和计时的时间间隔
        this.tv = tv;
    }

    @Override
    public void onFinish() {// 计时完毕时触发
        tv.setText("发送验证码");
        tv.setClickable(true);
    }

    @Override
    public void onTick(long millisUntilFinished) {// 计时过程显示
        tv.setClickable(false);
        tv.setText(millisUntilFinished / 1000 + "秒");
    }
}
